// 虚拟商品数据
export const products = [
  // 热门推荐商品
  {
    id: 1,
    name: 'Apple iPhone 13',
    price: 5999,
    img: 'https://picsum.photos/id/1/200/200',
    categoryIds: [102],
  },
  {
    id: 2,
    name: '三星 Galaxy Z Fold4',
    price: 12999,
    img: 'https://picsum.photos/id/2/200/200',
    categoryIds: [105],
  },
  {
    id: 3,
    name: '小米13 Pro',
    price: 5299,
    img: 'https://picsum.photos/id/3/200/200',
    categoryIds: [101, 103],
  },
  {
    id: 4,
    name: '华为 MateBook X Pro',
    price: 8999,
    img: 'https://picsum.photos/id/4/200/200',
    categoryIds: [203],
  },
  {
    id: 5,
    name: '格力空调 KFR-35GW',
    price: 2999,
    img: 'https://picsum.photos/id/5/200/200',
    categoryIds: [301],
  },
  {
    id: 6,
    name: '海尔对开门冰箱',
    price: 4599,
    img: 'https://picsum.photos/id/6/200/200',
    categoryIds: [302],
  },
  {
    id: 7,
    name: '美的滚筒洗衣机',
    price: 2799,
    img: 'https://picsum.photos/id/7/200/200',
    categoryIds: [303],
  },
  {
    id: 8,
    name: '海信 55英寸 4K电视',
    price: 2399,
    img: 'https://picsum.photos/id/8/200/200',
    categoryIds: [304],
  },
  {
    id: 9,
    name: '戴森空气净化器',
    price: 4990,
    img: 'https://picsum.photos/id/9/200/200',
    categoryIds: [401],
  },
  {
    id: 10,
    name: '苏泊尔电火锅',
    price: 299,
    img: 'https://picsum.photos/id/10/200/200',
    categoryIds: [402],
  },
  {
    id: 11,
    name: '茅台飞天 53度',
    price: 1499,
    img: 'https://picsum.photos/id/11/200/200',
    categoryIds: [502],
  },
  {
    id: 12,
    name: '伊利纯牛奶',
    price: 68,
    img: 'https://picsum.photos/id/12/200/200',
    categoryIds: [503],
  },
  {
    id: 13,
    name: '帮宝适纸尿裤',
    price: 129,
    img: 'https://picsum.photos/id/13/200/200',
    categoryIds: [601],
  },
  {
    id: 14,
    name: '维达抽纸',
    price: 39.9,
    img: 'https://picsum.photos/id/14/200/200',
    categoryIds: [701],
  },
  {
    id: 15,
    name: '兰蔻护肤套装',
    price: 899,
    img: 'https://picsum.photos/id/15/200/200',
    categoryIds: [702],
  },
  {
    id: 16,
    name: '百亿补贴专场',
    price: 999,
    img: 'https://picsum.photos/id/16/200/200',
    categoryIds: [802],
  },
]

// 根据分类ID筛选商品
export const getProductsByCategoryId = categoryId => {
  return products.filter(product => product.categoryIds.includes(categoryId))
}

// 获取热门推荐商品
export const getHotRecommendedProducts = (count = 8) => {
  return products.slice(0, count)
}

// 根据商品ID获取商品详情
export const getProductById = productId => {
  return products.find(product => product.id === productId) || null
}

// 搜索商品
export const searchProducts = keyword => {
  if (!keyword || keyword.trim() === '') {
    return []
  }
  const lowerKeyword = keyword.toLowerCase()
  return products.filter(product => product.name.toLowerCase().includes(lowerKeyword))
}
